// 单链表节点
function ListNode(val, next) {
    this.val = (val == undefined ? 0 : val)
    this.next = (next == undefined ? null : next)
}

function reverseList(head) {
// TODO
    if (head == null) return head;
    let l = null;
    let r = head;
    while(r!=null){
        let t = r.next
        r.next = l
        l = r
        r = t
    }
    return l
};
let head = new ListNode(1)
head.next = new ListNode(2)
head.next.next = new ListNode(3)
console.log(reverseList(head))